//
// Copyright (C) 2011 Steve Channell steve.channell@cepheis.com
//
// This file is part of Cephei.QL, an open-source library wrapper 
// arround QuantLib http://quantlib.org/
//
// Cephei.QL is open source software: you can redistribute it and/or modify it
// under the terms of the license.  You should have received a
// copy of the license along with this program; if not, please email
// <support@cepheis.com>. The license is also available online at
// <http://cepheis.com/license.htm>.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE.  See the license for more details.
//
// Version 2.101
//#include "stdafx.h"
#include "CapFloorTermVolCurve.h"
using namespace Cephei::QL::Termstructures::Volatility::Capfloor;
#include <gen/QL/Times/Calendar.h>
#include <gen/QL/Times/Period.h>
#include <gen/QL/Times/DayCounter.h>
#include <gen/QL/Quote.h>
#include <gen/QL/Termstructures/Volatility/Capfloor/CapFloorTermVolatilityStructure.h>
using namespace Cephei::QL::Times;
using namespace Cephei::QL;
#define HANDLE
#undef ABSTRACT
#undef STRUCT
Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::CCapFloorTermVolCurve (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc) : CCapFloorTermVolatilityStructure(CCapFloorTermVolCurve::typeid)
{
    CCalendar^ _Ccalendar;
    CoVector<Cephei::QL::Times::IPeriod^>^ _CoptionTenors;
    CoVector<Double>^ _Cvols;
    CDayCounter^ _Cdc;
    try
    {
#ifdef HANDLE
        _phCapFloorTermVolCurve = NULL;
#endif
        QuantLib::Natural _settlementDays = (QuantLib::Natural)ValueHelper::Convert (settlementDays);
        _Ccalendar = safe_cast<CCalendar^> (calendar);
        _Ccalendar->Lock();
        QuantLib::Calendar& _calendar = static_cast<QuantLib::Calendar&> (_Ccalendar->GetReference ()); 
        QuantLib::BusinessDayConvention _bdc = (QuantLib::BusinessDayConvention)bdc ;
        _CoptionTenors = safe_cast<CoVector<Cephei::QL::Times::IPeriod^>^> (optionTenors);
        _CoptionTenors ->Lock ();
        INativeVector<Cephei::QL::Times::IPeriod^>^ _NCIoptionTenors = _CoptionTenors->getFeature (NativeFeature::Value);
        CPeriodVector^ _NCoptionTenors = safe_cast<CPeriodVector^>(_NCIoptionTenors);
        std::vector<QuantLib::Period>& _optionTenors = static_cast<std::vector<QuantLib::Period>&> (_NCoptionTenors->GetReference ());
        CoVector<Double>^ _Cvols = safe_cast<CoVector<Double>^> (vols);
        _Cvols->Lock();
        INativeVector<Double>^ _NCIvols = _Cvols->getFeature (NativeFeature::Value);
        CDoubleVector^ _NCvols = safe_cast<CDoubleVector^>(_NCIvols);
        std::vector<QuantLib::Volatility>& _vols = static_cast<std::vector<QuantLib::Volatility>&> (_NCvols->GetReference ());
        if (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>::IsSome::get (dc))
        {
            _Cdc = safe_cast<CDayCounter^> (dc->Value);
            _Cdc->Lock();
        }
        QuantLib::DayCounter& _dc = 
            (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>::IsSome::get (dc) ? static_cast<QuantLib::DayCounter&> (_Cdc->GetReference ()) : QuantLib::Actual365Fixed()); //1
        _ppCapFloorTermVolCurve = new boost::shared_ptr<QuantLib::CapFloorTermVolCurve> (new QuantLib::CapFloorTermVolCurve ( _settlementDays,  _calendar,  _bdc,  _optionTenors,  _vols,  _dc ));
        SetCapFloorTermVolatilityStructure (boost::dynamic_pointer_cast<QuantLib::CapFloorTermVolatilityStructure> (*_ppCapFloorTermVolCurve));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
        if (_Ccalendar != nullptr) _Ccalendar->Unlock();
        if (_CoptionTenors != nullptr) _CoptionTenors->Unlock();
        if (_Cvols != nullptr) _Cvols->Unlock();
        if (_Cdc != nullptr) _Cdc->Unlock();
    }
}
Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::CCapFloorTermVolCurve (DateTime settlementDate, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc) : CCapFloorTermVolatilityStructure(CCapFloorTermVolCurve::typeid)
{
    CCalendar^ _Ccalendar;
    CoVector<Cephei::QL::Times::IPeriod^>^ _CoptionTenors;
    CoVector<Double>^ _Cvols;
    CDayCounter^ _Cdc;
    try
    {
#ifdef HANDLE
        _phCapFloorTermVolCurve = NULL;
#endif
        QuantLib::Date _settlementDate = (QuantLib::Date)ValueHelper::Convert (settlementDate);
        _Ccalendar = safe_cast<CCalendar^> (calendar);
        _Ccalendar->Lock();
        QuantLib::Calendar& _calendar = static_cast<QuantLib::Calendar&> (_Ccalendar->GetReference ()); 
        QuantLib::BusinessDayConvention _bdc = (QuantLib::BusinessDayConvention)bdc ;
        _CoptionTenors = safe_cast<CoVector<Cephei::QL::Times::IPeriod^>^> (optionTenors);
        _CoptionTenors ->Lock ();
        INativeVector<Cephei::QL::Times::IPeriod^>^ _NCIoptionTenors = _CoptionTenors->getFeature (NativeFeature::Value);
        CPeriodVector^ _NCoptionTenors = safe_cast<CPeriodVector^>(_NCIoptionTenors);
        std::vector<QuantLib::Period>& _optionTenors = static_cast<std::vector<QuantLib::Period>&> (_NCoptionTenors->GetReference ());
        CoVector<Double>^ _Cvols = safe_cast<CoVector<Double>^> (vols);
        _Cvols->Lock();
        INativeVector<Double>^ _NCIvols = _Cvols->getFeature (NativeFeature::Value);
        CDoubleVector^ _NCvols = safe_cast<CDoubleVector^>(_NCIvols);
        std::vector<QuantLib::Volatility>& _vols = static_cast<std::vector<QuantLib::Volatility>&> (_NCvols->GetReference ());
        if (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>::IsSome::get (dc))
        {
            _Cdc = safe_cast<CDayCounter^> (dc->Value);
            _Cdc->Lock();
        }
        QuantLib::DayCounter& _dc = 
            (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>::IsSome::get (dc) ? static_cast<QuantLib::DayCounter&> (_Cdc->GetReference ()) : QuantLib::Actual365Fixed()); //1
        _ppCapFloorTermVolCurve = new boost::shared_ptr<QuantLib::CapFloorTermVolCurve> (new QuantLib::CapFloorTermVolCurve ( _settlementDate,  _calendar,  _bdc,  _optionTenors,  _vols,  _dc ));
        SetCapFloorTermVolatilityStructure (boost::dynamic_pointer_cast<QuantLib::CapFloorTermVolatilityStructure> (*_ppCapFloorTermVolCurve));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
        if (_Ccalendar != nullptr) _Ccalendar->Unlock();
        if (_CoptionTenors != nullptr) _CoptionTenors->Unlock();
        if (_Cvols != nullptr) _Cvols->Unlock();
        if (_Cdc != nullptr) _Cdc->Unlock();
    }
}
Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::CCapFloorTermVolCurve (DateTime settlementDate, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Cephei::QL::IQuote^>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc) : CCapFloorTermVolatilityStructure(CCapFloorTermVolCurve::typeid)
{
    CCalendar^ _Ccalendar;
    CoVector<Cephei::QL::Times::IPeriod^>^ _CoptionTenors;
    CoVector<Cephei::QL::IQuote^>^ _Cvols;
    CDayCounter^ _Cdc;
    try
    {
#ifdef HANDLE
        _phCapFloorTermVolCurve = NULL;
#endif
        QuantLib::Date _settlementDate = (QuantLib::Date)ValueHelper::Convert (settlementDate);
        _Ccalendar = safe_cast<CCalendar^> (calendar);
        _Ccalendar->Lock();
        QuantLib::Calendar& _calendar = static_cast<QuantLib::Calendar&> (_Ccalendar->GetReference ()); 
        QuantLib::BusinessDayConvention _bdc = (QuantLib::BusinessDayConvention)bdc ;
        _CoptionTenors = safe_cast<CoVector<Cephei::QL::Times::IPeriod^>^> (optionTenors);
        _CoptionTenors ->Lock ();
        INativeVector<Cephei::QL::Times::IPeriod^>^ _NCIoptionTenors = _CoptionTenors->getFeature (NativeFeature::Value);
        CPeriodVector^ _NCoptionTenors = safe_cast<CPeriodVector^>(_NCIoptionTenors);
        std::vector<QuantLib::Period>& _optionTenors = static_cast<std::vector<QuantLib::Period>&> (_NCoptionTenors->GetReference ());
        _Cvols = safe_cast<CoVector<Cephei::QL::IQuote^>^> (vols);
        _Cvols ->Lock ();
        INativeVector<Cephei::QL::IQuote^>^ _NCIvols = _Cvols->getFeature (NativeFeature::Handle);
        CQuoteVector^ _NCvols = safe_cast<CQuoteVector^>(_NCIvols);
        std::vector<Handle<QuantLib::Quote> >& _vols = static_cast<std::vector<Handle<QuantLib::Quote> >&> (_NCvols->GetHandle ());
        if (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>::IsSome::get (dc))
        {
            _Cdc = safe_cast<CDayCounter^> (dc->Value);
            _Cdc->Lock();
        }
        QuantLib::DayCounter& _dc = 
            (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>::IsSome::get (dc) ? static_cast<QuantLib::DayCounter&> (_Cdc->GetReference ()) : QuantLib::Actual365Fixed()); //1
        _ppCapFloorTermVolCurve = new boost::shared_ptr<QuantLib::CapFloorTermVolCurve> (new QuantLib::CapFloorTermVolCurve ( _settlementDate,  _calendar,  _bdc,  _optionTenors,  _vols,  _dc ));
        SetCapFloorTermVolatilityStructure (boost::dynamic_pointer_cast<QuantLib::CapFloorTermVolatilityStructure> (*_ppCapFloorTermVolCurve));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
        if (_Ccalendar != nullptr) _Ccalendar->Unlock();
        if (_CoptionTenors != nullptr) _CoptionTenors->Unlock();
        if (_Cvols != nullptr) _Cvols->Unlock();
        if (_Cdc != nullptr) _Cdc->Unlock();
    }
}
Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::CCapFloorTermVolCurve (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Cephei::QL::IQuote^>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc) : CCapFloorTermVolatilityStructure(CCapFloorTermVolCurve::typeid)
{
    CCalendar^ _Ccalendar;
    CoVector<Cephei::QL::Times::IPeriod^>^ _CoptionTenors;
    CoVector<Cephei::QL::IQuote^>^ _Cvols;
    CDayCounter^ _Cdc;
    try
    {
#ifdef HANDLE
        _phCapFloorTermVolCurve = NULL;
#endif
        QuantLib::Natural _settlementDays = (QuantLib::Natural)ValueHelper::Convert (settlementDays);
        _Ccalendar = safe_cast<CCalendar^> (calendar);
        _Ccalendar->Lock();
        QuantLib::Calendar& _calendar = static_cast<QuantLib::Calendar&> (_Ccalendar->GetReference ()); 
        QuantLib::BusinessDayConvention _bdc = (QuantLib::BusinessDayConvention)bdc ;
        _CoptionTenors = safe_cast<CoVector<Cephei::QL::Times::IPeriod^>^> (optionTenors);
        _CoptionTenors ->Lock ();
        INativeVector<Cephei::QL::Times::IPeriod^>^ _NCIoptionTenors = _CoptionTenors->getFeature (NativeFeature::Value);
        CPeriodVector^ _NCoptionTenors = safe_cast<CPeriodVector^>(_NCIoptionTenors);
        std::vector<QuantLib::Period>& _optionTenors = static_cast<std::vector<QuantLib::Period>&> (_NCoptionTenors->GetReference ());
        _Cvols = safe_cast<CoVector<Cephei::QL::IQuote^>^> (vols);
        _Cvols ->Lock ();
        INativeVector<Cephei::QL::IQuote^>^ _NCIvols = _Cvols->getFeature (NativeFeature::Handle);
        CQuoteVector^ _NCvols = safe_cast<CQuoteVector^>(_NCIvols);
        std::vector<Handle<QuantLib::Quote> >& _vols = static_cast<std::vector<Handle<QuantLib::Quote> >&> (_NCvols->GetHandle ());
        if (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>::IsSome::get (dc))
        {
            _Cdc = safe_cast<CDayCounter^> (dc->Value);
            _Cdc->Lock();
        }
        QuantLib::DayCounter& _dc = 
            (Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>::IsSome::get (dc) ? static_cast<QuantLib::DayCounter&> (_Cdc->GetReference ()) : QuantLib::Actual365Fixed()); //1
        _ppCapFloorTermVolCurve = new boost::shared_ptr<QuantLib::CapFloorTermVolCurve> (new QuantLib::CapFloorTermVolCurve ( _settlementDays,  _calendar,  _bdc,  _optionTenors,  _vols,  _dc ));
        SetCapFloorTermVolatilityStructure (boost::dynamic_pointer_cast<QuantLib::CapFloorTermVolatilityStructure> (*_ppCapFloorTermVolCurve));
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
        if (_Ccalendar != nullptr) _Ccalendar->Unlock();
        if (_CoptionTenors != nullptr) _CoptionTenors->Unlock();
        if (_Cvols != nullptr) _Cvols->Unlock();
        if (_Cdc != nullptr) _Cdc->Unlock();
    }
}
Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::CCapFloorTermVolCurve (boost::shared_ptr<QuantLib::CapFloorTermVolCurve>& childNative, Object^ owner) : CCapFloorTermVolatilityStructure(CCapFloorTermVolCurve::typeid)
{
#ifdef HANDLE
	_phCapFloorTermVolCurve = NULL;
#endif
	_ppCapFloorTermVolCurve = &childNative;
    _ppCapFloorTermVolatilityStructure = new boost::shared_ptr<QuantLib::CapFloorTermVolatilityStructure> (boost::dynamic_pointer_cast<QuantLib::CapFloorTermVolatilityStructure> (*_ppCapFloorTermVolCurve));
}
Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::CCapFloorTermVolCurve (QuantLib::CapFloorTermVolCurve& childNative, Object^ owner) : CCapFloorTermVolatilityStructure(CCapFloorTermVolCurve::typeid)
{
#ifdef HANDLE
	_phCapFloorTermVolCurve = NULL;
#endif
	_ppCapFloorTermVolCurve = new boost::shared_ptr<QuantLib::CapFloorTermVolCurve> (&childNative);
    _ppCapFloorTermVolatilityStructure = new boost::shared_ptr<QuantLib::CapFloorTermVolatilityStructure> (boost::dynamic_pointer_cast<QuantLib::CapFloorTermVolatilityStructure> (*_ppCapFloorTermVolCurve));
    _CapFloorTermVolCurveOwner = owner;
    _CapFloorTermVolatilityStructureOwner = owner;
}

Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::CCapFloorTermVolCurve (CCapFloorTermVolCurve^ copy) : CCapFloorTermVolatilityStructure(CCapFloorTermVolCurve::typeid)
{
#ifdef HANDLE
	_phCapFloorTermVolCurve = NULL;
#endif
	if (copy->HasNative() != NULL)
    {
		_ppCapFloorTermVolCurve = new boost::shared_ptr<QuantLib::CapFloorTermVolCurve> (copy->GetShared());
        _ppCapFloorTermVolatilityStructure = new boost::shared_ptr<QuantLib::CapFloorTermVolatilityStructure> (boost::dynamic_pointer_cast<QuantLib::CapFloorTermVolatilityStructure> (*_ppCapFloorTermVolCurve));
    }
}
Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::CCapFloorTermVolCurve (System::Type^ t) : CCapFloorTermVolatilityStructure(CCapFloorTermVolCurve::typeid)
{
#ifdef HANDLE
	_phCapFloorTermVolCurve = NULL;
#endif
	if (!t->IsSubclassOf(CCapFloorTermVolCurve::typeid))
		throw gcnew Exception ("Invalid base-case init");
}
#ifdef HANDLE
Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::CCapFloorTermVolCurve (QuantLib::Handle<QuantLib::CapFloorTermVolCurve>& childNative, Object^ owner)  : CCapFloorTermVolatilityStructure(CCapFloorTermVolCurve::typeid)
{
	_phCapFloorTermVolCurve = &childNative;
	_ppCapFloorTermVolCurve = &static_cast<boost::shared_ptr<QuantLib::CapFloorTermVolCurve>>(childNative.currentLink());
    _ppCapFloorTermVolatilityStructure = new boost::shared_ptr<QuantLib::CapFloorTermVolatilityStructure> (boost::dynamic_pointer_cast<QuantLib::CapFloorTermVolatilityStructure> (*_ppCapFloorTermVolCurve));
    _CapFloorTermVolCurveOwner = owner;
}
Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::CCapFloorTermVolCurve (QuantLib::Handle<QuantLib::CapFloorTermVolCurve> childNative)  : CCapFloorTermVolatilityStructure(CCapFloorTermVolCurve::typeid)
{
	_phCapFloorTermVolCurve = &childNative;
	_ppCapFloorTermVolCurve = &static_cast<boost::shared_ptr<QuantLib::CapFloorTermVolCurve>>(childNative.currentLink());
    _ppCapFloorTermVolatilityStructure = new boost::shared_ptr<QuantLib::CapFloorTermVolatilityStructure> (boost::dynamic_pointer_cast<QuantLib::CapFloorTermVolatilityStructure> (*_ppCapFloorTermVolCurve));
}
#endif
#ifdef STRUCT
Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::CCapFloorTermVolCurve (QuantLib::CapFloorTermVolCurve childNative)  : CCapFloorTermVolatilityStructure(CCapFloorTermVolCurve::typeid)
{
#ifdef HANDLE
	_phCapFloorTermVolCurve = NULL;
#endif
	_ppCapFloorTermVolCurve = new boost::shared_ptr<QuantLib::CapFloorTermVolCurve> (new QuantLib::CapFloorTermVolCurve (childNative));
    _ppCapFloorTermVolatilityStructure = new boost::shared_ptr<QuantLib::CapFloorTermVolatilityStructure> (boost::dynamic_pointer_cast<QuantLib::CapFloorTermVolatilityStructure> (*_ppCapFloorTermVolCurve));
}
#endif

Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::~CCapFloorTermVolCurve ()
{
    if (_ppCapFloorTermVolCurve != NULL)
    {
	    delete _ppCapFloorTermVolCurve;
        _ppCapFloorTermVolCurve = NULL;
    }
}
Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::!CCapFloorTermVolCurve ()
{
    if (_ppCapFloorTermVolCurve != NULL)
    {
	    delete _ppCapFloorTermVolCurve;
    }
}
QuantLib::CapFloorTermVolCurve& Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::GetReference ()
{
    if (_ppCapFloorTermVolCurve == NULL) throw gcnew NativeNullException ();
	return **_ppCapFloorTermVolCurve;
}
boost::shared_ptr<QuantLib::CapFloorTermVolCurve>& Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::GetShared ()
{
    if (_ppCapFloorTermVolCurve == NULL) throw gcnew NativeNullException ();
	return *_ppCapFloorTermVolCurve;
}
QuantLib::CapFloorTermVolCurve* Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::GetPointer ()
{
    if (_ppCapFloorTermVolCurve == NULL) throw gcnew NativeNullException ();
	return &**_ppCapFloorTermVolCurve;
}
#ifdef HANDLE
QuantLib::Handle<QuantLib::CapFloorTermVolCurve>& Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::GetHandle ()
{
	if (_phCapFloorTermVolCurve == NULL)
	{
		_phCapFloorTermVolCurve = new Handle<QuantLib::CapFloorTermVolCurve> (*_ppCapFloorTermVolCurve);
	}
	return *_phCapFloorTermVolCurve;
}
#endif
bool Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::HasNative () 
{
	return (_ppCapFloorTermVolCurve != NULL);
}

DateTime Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::MaxDate::get ()
{
    try
    {
    	QuantLib::Date _rv = (QuantLib::Date)(*_ppCapFloorTermVolCurve)->maxDate ( );   
        DateTime _nrv = (DateTime)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::MaxStrike::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppCapFloorTermVolCurve)->maxStrike ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Double Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::MinStrike::get ()
{
    try
    {
    	QuantLib::Real _rv = (QuantLib::Real)(*_ppCapFloorTermVolCurve)->minStrike ( );   
        Double _nrv = (Double)ValueHelper::Convert (_rv);
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::IVector<DateTime>^ Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::OptionDates::get ()
{
    try
    {
    	std::vector<QuantLib::Date>& _rv = (std::vector<QuantLib::Date>&)(*_ppCapFloorTermVolCurve)->optionDates ( );   
        Cephei::IVector<DateTime>^ _nrv = gcnew CoVector<DateTime> (gcnew CDateTimeVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::IVector<Cephei::QL::Times::IPeriod^>^ Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::OptionTenors::get ()
{
    try
    {
    	std::vector<QuantLib::Period>& _rv = (std::vector<QuantLib::Period>&)(*_ppCapFloorTermVolCurve)->optionTenors ( );   
        CoVector<Cephei::QL::Times::IPeriod^>^ _nrv = gcnew CoVector<Cephei::QL::Times::IPeriod^>(gcnew CPeriodVector (_rv, this));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::IVector<Double>^ Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::OptionTimes::get ()
{
    try
    {
    	std::vector<QuantLib::Time>& _rv = (std::vector<QuantLib::Time>&)(*_ppCapFloorTermVolCurve)->optionTimes ( );   
        Cephei::IVector<Double>^ _nrv = gcnew CoVector<Double> (gcnew CDoubleVector (_rv));
    	return _nrv;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolCurve^ Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::PerformCalculations::get ()
{
    try
    {
    	(*_ppCapFloorTermVolCurve)->performCalculations ( );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolCurve^ Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve::Update::get ()
{
    try
    {
    	boost::detail::spinlock::scoped_lock lock (*_pSpinlock);
    	(*_ppCapFloorTermVolCurve)->update ( );
    	return this;
	}
    catch (QuantLib::Error& _error)
    {
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown quantlib error"));
        
    }
	catch (std::exception& _error)
	{
        if (_error.what())
		    throw gcnew NativeExcpetion (gcnew System::String(_error.what()));
        else
		    throw gcnew NativeExcpetion (gcnew System::String("Unknown std::exception"));
	}
    finally
    {
    }
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Factory class

Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolCurve^ Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve_Factory::Create (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc)
{
    return gcnew CCapFloorTermVolCurve ( settlementDays,  calendar,  bdc,  optionTenors,  vols,  dc);
}
Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolCurve^ Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve_Factory::Create (DateTime settlementDate, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Double>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc)
{
    return gcnew CCapFloorTermVolCurve ( settlementDate,  calendar,  bdc,  optionTenors,  vols,  dc);
}
Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolCurve^ Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve_Factory::Create (DateTime settlementDate, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Cephei::QL::IQuote^>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc)
{
    return gcnew CCapFloorTermVolCurve ( settlementDate,  calendar,  bdc,  optionTenors,  vols,  dc);
}
Cephei::QL::Termstructures::Volatility::Capfloor::ICapFloorTermVolCurve^ Cephei::QL::Termstructures::Volatility::Capfloor::CCapFloorTermVolCurve_Factory::Create (UInt32 settlementDays, Cephei::QL::Times::ICalendar^ calendar, QL::Times::BusinessDayConventionEnum bdc, Cephei::IVector<Cephei::QL::Times::IPeriod^>^ optionTenors, Cephei::IVector<Cephei::QL::IQuote^>^ vols, Microsoft::FSharp::Core::FSharpOption<Cephei::QL::Times::IDayCounter^>^ dc)
{
    return gcnew CCapFloorTermVolCurve ( settlementDays,  calendar,  bdc,  optionTenors,  vols,  dc);
}
